package project.parser.ast.stats;

import project.environments.DynamicEnv;
import project.environments.Value;
import project.parser.ast.exps.Exp;
import project.parser.tokenizer.TokenType;

public class While extends ConFlow {

	public While(Exp cond, Stat body) {
		super(cond, body);
	}

	@Override
	public void evaluate(DynamicEnv denv) {
		Value condValue = cond.evaluate(denv);
		while (condValue.asBoolean()) {
			body.evaluate(denv);
			condValue = cond.evaluate(denv);
		}
	}

	@Override
	public String condName() {
		return TokenType.WHILE.toString();
	}
}
